<!DOCTYPE html>
<html lang=zh>
<head>
    <!-- so meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="HandheldFriendly" content="True">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5" />
    <meta name="description" content="一.前期准备1.关闭防火墙 如果您使用的是CentOS或RHEL发行版，并且使用的是Firewalld防火墙软件，则可以使用以下命令关闭防火墙： 1234#查看防火墙命令systemctl status firewalld#关闭防火墙命令sudo systemctl stop firewalld  如果您想要在系统重新启动后保持防火墙关闭状态，则可以使用以下命令： 1sudo systemctl">
<meta property="og:type" content="article">
<meta property="og:title" content="Hadoop伪分布模式搭建">
<meta property="og:url" content="https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/index.html">
<meta property="og:site_name" content="Cactus">
<meta property="og:description" content="一.前期准备1.关闭防火墙 如果您使用的是CentOS或RHEL发行版，并且使用的是Firewalld防火墙软件，则可以使用以下命令关闭防火墙： 1234#查看防火墙命令systemctl status firewalld#关闭防火墙命令sudo systemctl stop firewalld  如果您想要在系统重新启动后保持防火墙关闭状态，则可以使用以下命令： 1sudo systemctl">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2023-04-12T13:09:26.000Z">
<meta property="article:modified_time" content="2023-04-20T06:23:28.019Z">
<meta property="article:author" content="云雪">
<meta property="article:tag" content="大数据">
<meta name="twitter:card" content="summary">
    
    
      
        
          <link rel="shortcut icon" href="/images/favicon.ico">
        
      
      
        
          <link rel="icon" type="image/png" href="/images/favicon-192x192.png" sizes="192x192">
        
      
      
        
          <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png">
        
      
    
    <!-- title -->
    <title>Hadoop伪分布模式搭建</title>

    <!-- styles -->
    
<link rel="stylesheet" href="/css/style.css">


     <!-- 添加到这里！！ -->
     
<script src="/js/switch.js"></script>


    <!-- persian styles -->
    
    <!-- rss -->
    
    
	<!-- mathjax -->
	
<meta name="generator" content="Hexo 6.3.0"><link rel="alternate" href="/atom.xml" title="Cactus" type="application/atom+xml">
</head>

<body class="max-width mx-auto px3 ltr">
    
      <div id="header-post">
  <a id="menu-icon" href="#" aria-label="目录"><i class="fas fa-bars fa-lg"></i></a>
  <a id="menu-icon-tablet" href="#" aria-label="目录"><i class="fas fa-bars fa-lg"></i></a>
  <a id="top-icon-tablet" href="#" aria-label="顶部" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');" style="display:none;"><i class="fas fa-chevron-up fa-lg"></i></a>
  <span id="menu">
    <span id="nav">
      <ul>
        <!--
       --><li><a href="/">首页</a></li><!--
     --><!--
       --><li><a href="/about/">关于</a></li><!--
     --><!--
       --><li><a href="/archives/">归档</a></li><!--
     --><!--
       --><li><a href="/categories/">分类</a></li><!--
     --><!--
       --><li><a href="/search/">搜索</a></li><!--
     -->
      </ul>
    </span>
    <br/>
    <span id="actions">
      <ul>
        
        <li><a class="icon" aria-label="上一篇" href="/Git/"><i class="fas fa-chevron-left" aria-hidden="true" onmouseover="$('#i-prev').toggle();" onmouseout="$('#i-prev').toggle();"></i></a></li>
        
        
        <li><a class="icon" aria-label="下一篇" href="/Vue/"><i class="fas fa-chevron-right" aria-hidden="true" onmouseover="$('#i-next').toggle();" onmouseout="$('#i-next').toggle();"></i></a></li>
        
        <li><a class="icon" aria-label="返回顶部" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up" aria-hidden="true" onmouseover="$('#i-top').toggle();" onmouseout="$('#i-top').toggle();"></i></a></li>
        <li><a class="icon" aria-label="分享文章" href="#"><i class="fas fa-share-alt" aria-hidden="true" onmouseover="$('#i-share').toggle();" onmouseout="$('#i-share').toggle();" onclick="$('#share').toggle();return false;"></i></a></li>

        <li><a class="icon" aria-label="切换主题 " href="#"><i class="fas fa-lightbulb" aria-hidden="true" onmouseover="$('#i-switch').toggle();" onmouseout="$('#i-switch').toggle();" onclick="switchNightMode();return false";></i></a></li>

      </ul>
      <span id="i-prev" class="info" style="display:none;">上一篇</span>
      <span id="i-next" class="info" style="display:none;">下一篇</span>
      <span id="i-top" class="info" style="display:none;">返回顶部</span>
      <span id="i-share" class="info" style="display:none;">分享文章</span>
      <span id="i-switch" class="info" style="display:none;">切换主题</span>
    </span>
    <br/>
    <div id="share" style="display: none">
      <ul>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.facebook.com/sharer.php?u=https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/"><i class="fab fa-facebook " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://twitter.com/share?url=https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/&text=Hadoop伪分布模式搭建"><i class="fab fa-twitter " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.linkedin.com/shareArticle?url=https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/&title=Hadoop伪分布模式搭建"><i class="fab fa-linkedin " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://pinterest.com/pin/create/bookmarklet/?url=https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/&is_video=false&description=Hadoop伪分布模式搭建"><i class="fab fa-pinterest " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=Hadoop伪分布模式搭建&body=Check out this article: https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/"><i class="fas fa-envelope " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://getpocket.com/save?url=https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/&title=Hadoop伪分布模式搭建"><i class="fab fa-get-pocket " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://reddit.com/submit?url=https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/&title=Hadoop伪分布模式搭建"><i class="fab fa-reddit " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.stumbleupon.com/submit?url=https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/&title=Hadoop伪分布模式搭建"><i class="fab fa-stumbleupon " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://digg.com/submit?url=https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/&title=Hadoop伪分布模式搭建"><i class="fab fa-digg " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.tumblr.com/share/link?url=https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/&name=Hadoop伪分布模式搭建&description="><i class="fab fa-tumblr " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://news.ycombinator.com/submitlink?u=https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/&t=Hadoop伪分布模式搭建"><i class="fab fa-hacker-news " aria-hidden="true"></i></a></li>
</ul>

    </div>
    <div id="toc">
      <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%80-%E5%89%8D%E6%9C%9F%E5%87%86%E5%A4%87"><span class="toc-number">1.</span> <span class="toc-text">一.前期准备</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-%E5%85%B3%E9%97%AD%E9%98%B2%E7%81%AB%E5%A2%99"><span class="toc-number">1.1.</span> <span class="toc-text">1.关闭防火墙</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-%E5%AE%89%E8%A3%85JDK%E5%8F%8A%E9%85%8D%E7%BD%AE"><span class="toc-number">1.2.</span> <span class="toc-text">2.安装JDK及配置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-%E5%AE%89%E8%A3%85Hadoop%E5%8F%8A%E9%85%8D%E7%BD%AE"><span class="toc-number">1.3.</span> <span class="toc-text">3.安装Hadoop及配置</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BA%8C-%E9%85%8D%E7%BD%AEHadoop%E7%9B%B8%E5%BA%94%E7%9A%84xml%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="toc-number">2.</span> <span class="toc-text">二.配置Hadoop相应的xml配置文件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%89-%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88"><span class="toc-number">3.</span> <span class="toc-text">三.常见问题解决方案</span></a></li></ol>
    </div>
  </span>
</div>

    
    <div class="content index py4">
        
        <article class="post" itemscope itemtype="http://schema.org/BlogPosting">
  <header>
    
    <h1 class="posttitle" itemprop="name headline">
        Hadoop伪分布模式搭建
    </h1>



    <div class="meta">
      <span class="author" itemprop="author" itemscope itemtype="http://schema.org/Person">
        <span itemprop="name">云雪</span>
      </span>
      
    <div class="postdate">
      
        <time datetime="2023-04-12T13:09:26.000Z" itemprop="datePublished">2023-04-12</time>
        
      
    </div>


      
    <div class="article-category">
        <i class="fas fa-archive"></i>
        <a class="category-link" href="/categories/%E8%AF%BE%E5%A4%96%E6%8B%93%E5%B1%95/">课外拓展</a>
    </div>


      
    <div class="article-tag">
        <i class="fas fa-tag"></i>
        <a class="tag-link-link" href="/tags/%E5%A4%A7%E6%95%B0%E6%8D%AE/" rel="tag">大数据</a>
    </div>


    </div>
  </header>
  

  <div class="content" itemprop="articleBody">
    <h2 id="一-前期准备"><a href="#一-前期准备" class="headerlink" title="一.前期准备"></a>一.前期准备</h2><h3 id="1-关闭防火墙"><a href="#1-关闭防火墙" class="headerlink" title="1.关闭防火墙"></a>1.关闭防火墙</h3><ol>
<li><p>如果您使用的是CentOS或RHEL发行版，并且使用的是Firewalld防火墙软件，则可以使用以下命令关闭防火墙：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">#查看防火墙命令</span><br><span class="line">systemctl status firewalld</span><br><span class="line">#关闭防火墙命令</span><br><span class="line">sudo systemctl stop firewalld</span><br></pre></td></tr></table></figure>

<p>如果您想要在系统重新启动后保持防火墙关闭状态，则可以使用以下命令：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo systemctl disable firewalld</span><br></pre></td></tr></table></figure>
</li>
<li><p>如果您使用的是CentOS或RHEL发行版，并且使用的是iptables防火墙软件，则可以使用以下命令关闭防火墙：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo systemctl stop iptables</span><br></pre></td></tr></table></figure>

<p>如果您想要在系统重新启动后保持防火墙关闭状态，则可以使用以下命令：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo systemctl disable iptables</span><br></pre></td></tr></table></figure></li>
</ol>
<h3 id="2-安装JDK及配置"><a href="#2-安装JDK及配置" class="headerlink" title="2.安装JDK及配置"></a>2.安装JDK及配置</h3><ol>
<li><p>使用压缩包安装JDK</p>
<ol>
<li><p>创建给JDK解压的目录</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">#安装目录可以进行随意修改</span><br><span class="line">sudo mkdir /usr/local/jdk</span><br></pre></td></tr></table></figure>
</li>
<li><p>使用以下命令将其解压缩：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">#1.跳转到安装目录</span><br><span class="line">cd /usr/local/jdk</span><br><span class="line">#2.执行解压命令，其中“xxxx”为你下载的JDK版本号</span><br><span class="line">tar -zxvf jdk-xxxx-linux-x64.tar.gz</span><br></pre></td></tr></table></figure>
</li>
<li><p>完成JDK的安装后，需要配置环境变量，以便系统可以找到JDK。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">#打开配置文件</span><br><span class="line">sudo vi /etc/profile</span><br></pre></td></tr></table></figure>

<p>文件末尾添加以下内容：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">#后面路径请填写你所安装的JDK路径</span><br><span class="line">export JAVA_HOME=/usr/local/jdk</span><br><span class="line">export PATH=$JAVA_HOME/bin:$PATH</span><br><span class="line">export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar</span><br></pre></td></tr></table></figure>

<p>保存并关闭文件，然后，使用以下命令使更改生效：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">source /etc/profile</span><br></pre></td></tr></table></figure>
</li>
<li><p>完成后，您可以使用以下命令检查JDK是否已正确安装：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">java -version</span><br></pre></td></tr></table></figure></li>
</ol>
</li>
<li><p>使用yum命令安装JDK（本人使用的方式）</p>
<ol>
<li><p>使用yum命令去仓库下载</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"># 这里以openjdk8为例</span><br><span class="line">yum install java-1.8.0-openjdk </span><br></pre></td></tr></table></figure>
</li>
<li><p>打开配置文件</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">#打开配置文件</span><br><span class="line">sudo vi /etc/profile</span><br></pre></td></tr></table></figure>
</li>
<li><p>文件末尾添加以下内容：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">#下载路径一般为 /usr/lib/jvm/ ，如果不是可以通过which Java进行查找下载安装的路径</span><br><span class="line">export JAVA_HOME=/usr/lib/jvm/java-<span class="number">1.8</span><span class="number">.0</span></span><br><span class="line">export JRE_HOME=$JAVA_HOME/jre</span><br><span class="line">export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin</span><br><span class="line">export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib</span><br></pre></td></tr></table></figure>
</li>
<li><p>保存并关闭文件。然后，使用以下命令使更改生效：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">source /etc/profile</span><br></pre></td></tr></table></figure>
</li>
<li><p>验证是否配置成功</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">java -version</span><br></pre></td></tr></table></figure></li>
</ol>
</li>
</ol>
<h3 id="3-安装Hadoop及配置"><a href="#3-安装Hadoop及配置" class="headerlink" title="3.安装Hadoop及配置"></a>3.安装Hadoop及配置</h3><ol>
<li><p>创建目录来安装Hadoop</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">#目录随意创建</span><br><span class="line">mkdir /opt/hadoop</span><br></pre></td></tr></table></figure>
</li>
<li><p>解压Hadoop压缩包</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">#跳转要解压的目录</span><br><span class="line">cd /opt/hadoop</span><br><span class="line"></span><br><span class="line">#解压压缩包</span><br><span class="line">tar -zxvf hadoop-3.3.0.tar.gz </span><br><span class="line"></span><br><span class="line">#或者可以使用下面命令,可以省略创建目录的过程</span><br><span class="line">tar -zxvf hadoop-3.3.0.tar.gz  -C  /opt/hadoop/</span><br></pre></td></tr></table></figure>
</li>
<li><p>配置Hadoop环境变量</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">#打开配置文件</span><br><span class="line">sudo vi /etc/profile</span><br></pre></td></tr></table></figure>
</li>
<li><p>文件末尾添加以下内容</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">#Hadoop路径以自己的安装路径为主</span><br><span class="line">export HADOOP_HOME=/opt/hadoop/hadoop-<span class="number">3.3</span><span class="number">.5</span></span><br><span class="line">export PATH=$PATH:$HADOOP_HOME/bin</span><br><span class="line">export PATH=$PATH:$HADOOP_HOME/sbin</span><br></pre></td></tr></table></figure>
</li>
<li><p>保存并关闭文件。然后，使用以下命令使更改生效：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">source /etc/profile</span><br></pre></td></tr></table></figure>
</li>
<li><p>验证是否配置成功</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hadoop version</span><br></pre></td></tr></table></figure></li>
</ol>
<h2 id="二-配置Hadoop相应的xml配置文件"><a href="#二-配置Hadoop相应的xml配置文件" class="headerlink" title="二.配置Hadoop相应的xml配置文件"></a>二.配置Hadoop相应的xml配置文件</h2><ol>
<li><p>创建暂存文件的文件夹</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mkdir -p /opt/hadoop/hadoop-3.3.5/tmp</span><br></pre></td></tr></table></figure>


</li>
<li><p>配置core-site.xml文件</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">#首先先到Hadoop配置文件目录</span><br><span class="line">cd /opt/hadoop/hadoop-3.3.5/etc/hadoop</span><br><span class="line"></span><br><span class="line">#进入文件之后，滑到文件最下边，在<span class="tag">&lt;<span class="name">configuration</span>&gt;</span><span class="tag">&lt;/<span class="name">configuration</span>&gt;</span>中添加如下内容</span><br><span class="line"></span><br><span class="line">#主要内容是配置NameNode所在的主机或者通讯地址及NameNode格式化后的目录的路径</span><br><span class="line">  <span class="tag">&lt;<span class="name">property</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>fs.defaultFS<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">value</span>&gt;</span>hdfs://master:9000<span class="tag">&lt;/<span class="name">value</span>&gt;</span>  #master 是我主机名，请更改为自己的主机名或者IP</span><br><span class="line">  <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span><br><span class="line">  </span><br><span class="line">  <span class="tag">&lt;<span class="name">property</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>hadoop.tmp.dir<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>/opt/hadoop/hadoop-3.3.5/tmp<span class="tag">&lt;/<span class="name">value</span>&gt;</span> #暂存文件夹路径</span><br><span class="line">  <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span><br><span class="line">  </span><br><span class="line">#添加好之后保存退出</span><br></pre></td></tr></table></figure>
</li>
<li><p>配置hdfs-site.xml文件</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">#进入hafs-site.xml配置文件命令</span><br><span class="line">vi hafs-site.xml</span><br><span class="line"></span><br><span class="line">#进入文件之后，滑到文件最下边，在<span class="tag">&lt;<span class="name">configuration</span>&gt;</span><span class="tag">&lt;/<span class="name">configuration</span>&gt;</span>中添加如下内容</span><br><span class="line"><span class="tag">&lt;<span class="name">property</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.replication<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">value</span>&gt;</span>1<span class="tag">&lt;/<span class="name">value</span>&gt;</span> #因为是伪分布模式，所以是1</span><br><span class="line"><span class="tag">&lt;/<span class="name">property</span>&gt;</span></span><br><span class="line"></span><br><span class="line">#添加好之后保存退出</span><br></pre></td></tr></table></figure>
</li>
<li><p>配置mapre-site.xml文件</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">#执行命令</span><br><span class="line">vi mapred-site.xml</span><br><span class="line"></span><br><span class="line">#进入文件之后，滑到文件最下边，在<span class="tag">&lt;<span class="name">configuration</span>&gt;</span><span class="tag">&lt;/<span class="name">configuration</span>&gt;</span>中添加如下内容</span><br><span class="line"> <span class="tag">&lt;<span class="name">property</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">name</span>&gt;</span>mapreduce.framework.name<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line">   <span class="tag">&lt;<span class="name">value</span>&gt;</span>yarn<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span><br><span class="line">   <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span><br><span class="line"></span><br><span class="line">#添加好之后保存退出</span><br></pre></td></tr></table></figure>
</li>
<li><p>配置yarn-site.xml文件</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"> #执行命令</span><br><span class="line"> vi yarn-site.xml</span><br><span class="line"> </span><br><span class="line">#进入文件之后，滑到文件最下边，在<span class="tag">&lt;<span class="name">configuration</span>&gt;</span><span class="tag">&lt;/<span class="name">configuration</span>&gt;</span>中添加如下内容</span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">property</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">name</span>&gt;</span>yarn.nodemanger.aux-services<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">value</span>&gt;</span>mapreduce_shuffle<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">property</span>&gt;</span></span><br><span class="line"></span><br><span class="line">#添加好之后保存退出</span><br></pre></td></tr></table></figure>
</li>
<li><p>配置Hadoop运行环境及配置hadoop-env.sh文件</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">#打开配置文件</span><br><span class="line">vi hadoop-env.sh</span><br><span class="line"></span><br><span class="line">#进入文件之后，添加jdk的环境变量，如下：</span><br><span class="line">export JAVA_HOME=/usr/lib/jvm/java-<span class="number">1.8</span><span class="number">.0</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>格式化NameNode</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hadoop  namenode  -format # 或者hdfs namenode -format</span><br></pre></td></tr></table></figure>


</li>
<li><p>启动服务并查看进程</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">#启动服务</span><br><span class="line">start-all.sh</span><br><span class="line"></span><br><span class="line">#查看进程</span><br><span class="line">jps</span><br></pre></td></tr></table></figure>
</li>
<li><p>使用web浏览器访问</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">#打开虚拟机的火狐浏览器，输入地址</span><br><span class="line">http://localhost:9870 //这里是虚拟机本机地址，以core-site.xml 配置文件中给定的IP地址或者主机名为准。</span><br></pre></td></tr></table></figure></li>
</ol>
<h2 id="三-常见问题解决方案"><a href="#三-常见问题解决方案" class="headerlink" title="三.常见问题解决方案"></a>三.常见问题解决方案</h2><blockquote>
<ul>
<li>由于本人没有遇到特别的问题，所以这里没有详细给出。</li>
<li>此文档不一定适合你的，但是可以提供一些参考，如你有好的意见或者有明显的错误，请跟我说一下，本人会及时修改。</li>
<li>感谢你从百忙中抽出时间看，最后祝你每天都开心，学业进步。</li>
</ul>
</blockquote>

  </div>
  <div id="copyright"><style>#easter-egg{border:0;padding:10px 0;position:relative}#easter-egg::before{font-family:"Font Awesome 5 Free";font-weight:900;content:"本文结束 \f1b0  感谢阅读";position:absolute;
padding:0 10px;
line-height:1px;
white-space:nowrap;
left:50%;
transform:translateX(-50%)}
</style><hr id="easter-egg"><blockquote style="padding:0">
    <p>作者: <a href="https://mihaoyou.gitee.io">
        <a1>云静</a1>
    </a></p>
    <p>版权声明: 本博客所有文章除特别声明外, 均采用 <a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)"><a1>CC BY-NC-ND 4.0</a1></a> 许可协议, 转载请注明出处！</p></blockquote><hr></div>
</article>


    <div class="blog-post-comments">
        <div id="utterances_thread">
            <noscript>加载评论需要在浏览器启用 JavaScript 脚本支持。</noscript>
        </div>
    </div>


        
          <div id="footer-post-container">
  <div id="footer-post">

    <div id="nav-footer" style="display: none">
      <ul>
         
          <li><a href="/">首页</a></li>
         
          <li><a href="/about/">关于</a></li>
         
          <li><a href="/archives/">归档</a></li>
         
          <li><a href="/categories/">分类</a></li>
         
          <li><a href="/search/">搜索</a></li>
        
      </ul>
    </div>

    <div id="toc-footer" style="display: none">
      <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%80-%E5%89%8D%E6%9C%9F%E5%87%86%E5%A4%87"><span class="toc-number">1.</span> <span class="toc-text">一.前期准备</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-%E5%85%B3%E9%97%AD%E9%98%B2%E7%81%AB%E5%A2%99"><span class="toc-number">1.1.</span> <span class="toc-text">1.关闭防火墙</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-%E5%AE%89%E8%A3%85JDK%E5%8F%8A%E9%85%8D%E7%BD%AE"><span class="toc-number">1.2.</span> <span class="toc-text">2.安装JDK及配置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-%E5%AE%89%E8%A3%85Hadoop%E5%8F%8A%E9%85%8D%E7%BD%AE"><span class="toc-number">1.3.</span> <span class="toc-text">3.安装Hadoop及配置</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BA%8C-%E9%85%8D%E7%BD%AEHadoop%E7%9B%B8%E5%BA%94%E7%9A%84xml%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="toc-number">2.</span> <span class="toc-text">二.配置Hadoop相应的xml配置文件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%89-%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88"><span class="toc-number">3.</span> <span class="toc-text">三.常见问题解决方案</span></a></li></ol>
    </div>

    <div id="share-footer" style="display: none">
      <ul>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.facebook.com/sharer.php?u=https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/"><i class="fab fa-facebook fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://twitter.com/share?url=https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/&text=Hadoop伪分布模式搭建"><i class="fab fa-twitter fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.linkedin.com/shareArticle?url=https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/&title=Hadoop伪分布模式搭建"><i class="fab fa-linkedin fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://pinterest.com/pin/create/bookmarklet/?url=https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/&is_video=false&description=Hadoop伪分布模式搭建"><i class="fab fa-pinterest fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=Hadoop伪分布模式搭建&body=Check out this article: https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/"><i class="fas fa-envelope fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://getpocket.com/save?url=https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/&title=Hadoop伪分布模式搭建"><i class="fab fa-get-pocket fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://reddit.com/submit?url=https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/&title=Hadoop伪分布模式搭建"><i class="fab fa-reddit fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.stumbleupon.com/submit?url=https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/&title=Hadoop伪分布模式搭建"><i class="fab fa-stumbleupon fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://digg.com/submit?url=https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/&title=Hadoop伪分布模式搭建"><i class="fab fa-digg fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.tumblr.com/share/link?url=https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/&name=Hadoop伪分布模式搭建&description="><i class="fab fa-tumblr fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://news.ycombinator.com/submitlink?u=https://mihaoyou.gitee.io/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E6%A8%A1%E5%BC%8F%E6%90%AD%E5%BB%BA/&t=Hadoop伪分布模式搭建"><i class="fab fa-hacker-news fa-lg" aria-hidden="true"></i></a></li>
</ul>

    </div>

    <div id="actions-footer">
        <a id="menu" class="icon" href="#" onclick="$('#nav-footer').toggle();return false;"><i class="fas fa-bars fa-lg" aria-hidden="true"></i> 菜单</a>
        <a id="toc" class="icon" href="#" onclick="$('#toc-footer').toggle();return false;"><i class="fas fa-list fa-lg" aria-hidden="true"></i> 目录</a>
        <a id="share" class="icon" href="#" onclick="$('#share-footer').toggle();return false;"><i class="fas fa-share-alt fa-lg" aria-hidden="true"></i> 分享</a>
        <a id="top" style="display:none" class="icon" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up fa-lg" aria-hidden="true"></i> 返回顶部</a>
    </div>

  </div>
</div>

        
        <footer id="footer">
      <div class="footer-left">
        Copyright &copy;
        
        
        2022-2023
        云雪
      </div>
      <div class="footer-right">
        <nav>
          <ul>
            <!--
          --><li><a href="/">首页</a></li><!--
        --><!--
          --><li><a href="/about/">关于</a></li><!--
        --><!--
          --><li><a href="/archives/">归档</a></li><!--
        --><!--
          --><li><a href="/categories/">分类</a></li><!--
        --><!--
          --><li><a href="/search/">搜索</a></li><!--
        -->
          </ul>
          <ul>
          
              <!-- 不蒜子统计 -->
              <span id="busuanzi_container_site_pv">
                  本站总访问量<span id="busuanzi_value_site_pv"></span>次
              </span>
              <span class="post-meta-divider">|</span>
              <span id="busuanzi_container_site_uv" style='display:none'>
                      本站访客数<span id="busuanzi_value_site_uv"></span>人
              </span>
            <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
            
          </ul>
        </nav>
      </div>
      
</footer>


    </div>
    <!-- styles -->



  <link rel="preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css" crossorigin="anonymous" onload="this.onload=null;this.rel='stylesheet'"/>


    <!-- jquery -->
 
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" crossorigin="anonymous"></script> 




<!-- clipboard -->

  
    <script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.7/clipboard.min.js" crossorigin="anonymous"></script> 
  
  <script type="text/javascript">
  $(function() {
    // copy-btn HTML
    var btn = "<span class=\"btn-copy tooltipped tooltipped-sw\" aria-label=\"复制到粘贴板！\">";
    btn += '<i class="far fa-clone"></i>';
    btn += '</span>'; 
    // mount it!
    $(".highlight table").before(btn);
    var clip = new ClipboardJS('.btn-copy', {
      text: function(trigger) {
        return Array.from(trigger.nextElementSibling.querySelectorAll('.code')).reduce((str,it)=>str+it.innerText+'\n','')
      }
    });
    clip.on('success', function(e) {
      e.trigger.setAttribute('aria-label', "复制成功！");
      e.clearSelection();
    })
  })
  </script>


<script src="/js/main.js"></script>

<!-- search -->

<!-- Google Analytics -->

<!-- Baidu Analytics -->

  <script type="text/javascript">
        var _hmt = _hmt || [];
        (function() {
          var hm = document.createElement("script");
          hm.src = "https://hm.baidu.com/hm.js?d052d72734717a430b46e4d07257350b";
          var s = document.getElementsByTagName("script")[0];
          s.parentNode.insertBefore(hm, s);
        })();
        </script>

<!-- Cloudflare Analytics -->

<!-- Umami Analytics -->

<!-- Disqus Comments -->

<!-- utterances Comments -->

    <script type="text/javascript">
      var utterances_repo = 'mihaoyou/huayu';
      var utterances_issue_term = 'pathname';
      var utterances_label = 'Comment';
      var utterances_theme = 'github-dark';

      (function(){
          var script = document.createElement('script');

          script.src = 'https://utteranc.es/client.js';
          script.setAttribute('repo', utterances_repo);
          script.setAttribute('issue-term', 'pathname');
          script.setAttribute('label', utterances_label);
          script.setAttribute('theme', utterances_theme);
          script.setAttribute('crossorigin', 'anonymous');
          script.async = true;
          (document.getElementById('utterances_thread')).appendChild(script);
      }());
  </script>

</body>
</html>
